package com.xiaocg.juc.future;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

public class FutureThreadPollDemo {
    public static void main(String[] args) throws Exception{
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(3, 10, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10));
        List<Future<String>> list = new ArrayList<>();
        for (int i =0;i<3;i++) {
            Future<String> submit = threadPoolExecutor.submit(new MyCallable());
            list.add(submit);
        }

        for (Future<String> future:list){
            String s = future.get();
            System.out.println(s);
        }

        threadPoolExecutor.shutdown();

        int i = ThreadLocalRandom.current().nextInt(10);
        System.out.println(i);

    }
}
